//
//  SelectCarCell.m
//  Cycling
//
//  Created by cjg.mini on 2023/3/13.
//

#import "SelectCarCell.h"

@implementation SelectCarCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setupUI];
    }
    return self;
}

- (void)setupUI {

    self.carImView = [[UIImageView alloc] init];
    self.carImView.image = [UIImage imageNamed:@"icon_mine_car_im"];
    [self.contentView addSubview:self.carImView];
    [self.carImView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.equalTo(self.contentView).offset(MARGIN_MIDDLE);
        make.bottom.equalTo(self.contentView).offset(-MARGIN_MIDDLE);
        make.size.mas_equalTo(CGSizeMake(84, 84));
    }];
    
    self.selectImView = [[UIImageView alloc] init];
    self.selectImView.image = [UIImage imageNamed:@"icon_not_select"];
    [self.contentView addSubview:self.selectImView];
    [self.selectImView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.contentView).offset(-MARGIN_MIDDLE);
        make.top.equalTo(self.contentView).offset(MARGIN_MIDDLE);
        make.size.mas_equalTo(CGSizeMake(24, 24));
    }];

    self.carNameLB = [[UILabel alloc] init];
    self.carNameLB.font = FONT_PRIMARY_TITLE;
    self.carNameLB.text = @"车辆名称";
    self.carNameLB.textColor = COLOR_BLACK;
    [self.contentView addSubview:self.carNameLB];
    [self.carNameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.top.equalTo(self.carImView.mas_top).offset(0);
        make.left.equalTo(self.carImView.mas_right).offset(MARGIN_MIDDLE);
        make.right.equalTo(self.selectImView.mas_left).offset(-MARGIN_MIDDLE);
    }];

    self.carTypeLB = [[UILabel alloc] init];
    self.carTypeLB.font = FONT_SECONDARY_TITLE;
    self.carTypeLB.text = @"车辆型号：SOOLEH系";
    self.carTypeLB.textColor = COLOR_NOT_SELECT;
    [self.contentView addSubview:self.carTypeLB];
    [self.carTypeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.centerY.mas_equalTo(self.carImView.mas_centerY);
        make.left.equalTo(self.carImView.mas_right).offset(MARGIN_MIDDLE);
        make.right.equalTo(self.contentView).offset(-MARGIN_MIDDLE);
    }];
    
    self.carFrameLB = [[UILabel alloc] init];
    self.carFrameLB.text = @"车架号：SOOLEH系";
    self.carFrameLB.font = FONT_SECONDARY_TITLE;
    self.carFrameLB.textColor = COLOR_NOT_SELECT;
    [self.contentView addSubview:self.carFrameLB];
    [self.carFrameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(30);
        make.bottom.equalTo(self.carImView.mas_bottom).offset(0);
        make.left.equalTo(self.carImView.mas_right).offset(MARGIN_MIDDLE);
        make.right.equalTo(self.contentView).offset(-MARGIN_MIDDLE);
    }];
    
}

-(void)setIsChoose:(BOOL)isChoose {
    _isChoose = isChoose;
    if (isChoose) {
        self.selectImView.image = [UIImage imageNamed:@"icon_select"];
    }else {
        self.selectImView.image = [UIImage imageNamed:@"icon_not_select"];
    }
}


@end
